package raycast;

import java.util.Collection;

import model.Light;
import model.Shader;
import model.primitive.Primitive;
import Camera.Camera;

public class Scene {
	/*private Image image;*/
	private Camera camera;
	private Collection<Shader> shaders;
	private Collection<Primitive> primitives;
	private Collection<Light> lights;
	
	public Scene() {
		super();
		
		/* Cambiar por un tipo concreto de coleccion */
		this.lights = null;
		this.shaders = null;
		this.primitives = null;
		this.camera = null;
	}
	
	public Scene( Collection<Light> lights, Collection<Shader> shaders, 
			Collection<Primitive> primitives ) {
		if (lights == null || shaders == null || primitives == null) {
			throw new IllegalArgumentException("Some of the arguments are null");
		}
		
		
		/* Definir la clase concreta de collection a usar e instanciarla*/
		
		this.lights.addAll(lights);
		this.shaders.addAll(shaders);
		this.primitives.addAll(primitives);
	}
	

	public Collection<Light> getLights() {
		return lights;
	}

	public void setLights(Collection<Light> lights) {
		this.lights.clear();
		
		if (lights != null) {
			this.lights.addAll(lights);
		}
	}
	
	public boolean addLight(Light l) {
		if (l != null) {
			return this.lights.add(l);
		}
		
		return false;
	}

	public boolean addLights(Collection<Light> lights) {
		if (lights != null) {
			return this.lights.addAll(lights);
		}
		
		return false;
	}
	
	public boolean removeLight(Light l) {
		if (l != null) {
			return this.lights.remove(l);
		}
		
		return false;
	}
	
	public boolean removeLights(Collection<Light> lights) {
		if (lights != null) {
			return this.lights.removeAll(lights);
		}
		
		return false;
	}
	
	public Collection<Shader> getShaders() {
		return shaders;
	}

	public void setShaders(Collection<Shader> shaders) {
		this.shaders.clear();
		
		if (shaders != null) {
			this.shaders.addAll(shaders);
		}
		this.shaders = shaders;
	}
	
	public boolean addShader(Shader s) {
		if (s != null) {
			return this.shaders.add(s);
		}
		
		return false;
	}
	
	public boolean addShaders(Collection<Shader> shaders) {
		if (shaders != null) {
			return this.shaders.addAll(shaders);
		}
		
		return false;
	}

	public boolean removeShader(Shader s) {
		if (s != null) {
			return this.shaders.remove(s);
		}
		
		return false;
	}
	
	public boolean removeShaders(Collection<Shader> shaders) {
		if (shaders != null) {
			return this.shaders.removeAll(shaders);
		}
		
		return false;
	}
	
	public Collection<Primitive> getPrimitives() {
		return primitives;
	}
	
	public void setPrimitives(Collection<Primitive> primitives) {
		this.primitives.clear();
		
		if (primitives != null) {
			this.primitives.addAll(primitives);
		}
	}
	
	public boolean addPrimitive(Primitive p) {
		if (p != null) {
			return this.primitives.add(p);
		}
		
		return false;
	}
	
	public boolean addPrimitives(Collection<Primitive> primitives) {
		if (primitives != null) {
			return this.primitives.addAll(primitives);
		}
		
		return false;
	}
	
	public boolean removePrimitive(Primitive p) {
		if (p != null) {
			return this.primitives.remove(p);
		}
		
		return false;
	}
	
	public boolean removePrimitives(Collection<Primitive> primitives) {
		if (primitives != null) {
			return this.primitives.removeAll(primitives);
		}
		
		return false;
	}

	public Camera getCamera() {
		return camera;
	}


	public void setCamera(Camera cam) {
		this.camera = cam;
	}
}
